<%@ page language="java" import="java.util.*" import="java.sql.*" import = "orm.*"  pageEncoding="utf-8" errorPage="errorPage.jsp"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href = <%=basePath%> />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改密码</title>
<link href="css/aStyles.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
	<%if (request.getAttribute("success") != null){ %>
	alert("修改成功！");<%request.removeAttribute("success");} 
	else if (request.getAttribute("error") != null){%> alert("<%=request.getAttribute("error")%>");<%request.removeAttribute("error");}%>
	function check(){
		if (document.getElementById("prePwd").value == ""){
			alert("请输入原密码！");
			return false;
		}
		if (document.getElementById("pwd").value == ""){
			alert("请输入新密码！");
			return false;
		}
		if (document.getElementById("pwdTwice").value == ""){
			alert("请再次输入新密码！");
			return false;
		}
		if (document.getElementById("pwd").value != document.getElementById("pwdTwice").value){
			alert("两次输入的新密码不一致！");
			return false;
		}
		if (document.getElementById("code").value == ""){
			alert("请输入验证码！");
			return false;
		}
		return true;
	}
	
	function commit(){
		if (check()){
			var opt = confirm("确定修改密码吗？");
			if (opt == true){
				this.modifyPwdForm.action = "modifyPwd.do?type=Admin";
				return this.modifyPwdForm.submit();
			}
			reset();
			return false;
		}
		reset();
		return false;
	}
	
	function reset(){
		document.getElementById("prePwd").value = "";
		document.getElementById("pwd").value = "";
		document.getElementById("pwdTwice").value = "";
		document.getElementById("code").value = "";
		document.getElementById("codePic").innerHTML = "<img src='images/code.jsp?" + new Date + "' />";
	}
</script>
</head>
<% 	User adm  =(User) session.getAttribute("Admin");  
	if (adm == null){
		response.sendRedirect(path + "/index.jsp");
	}
%>

<body>
	<!-- CONTAINER START -->
<div id = "container">
	<!-- HEADER START -->
        <div id = "top">
        	<div id = "navigation">
        		<html:link page="/admi/admi.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;首页</html:link>
                <html:link page="/admi/notice.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;通知</html:link>
                <html:link page="/admi/accMan.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;帐户管理</html:link>
                <html:link page="/admi/message.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;留言板管理</html:link>
            </div>
    	</div>
        <!-- HEADER END -->
        
	<!-- LOGIN START -->
        <div id = "login">
        	<html:link page="" styleClass="viewTest">·查看当前考试</html:link>
          	<p><html:link page="/admi/admModifyPwd.jsp" styleClass="modifyPwd">·修改密码</html:link></p>
            <p><html:link forward="logout" styleClass="logout">·注销登录</html:link></p>
  </div>
        <!-- LOGIN END -->
        
    	<!-- CLOCK START -->
  <div id = "clock">
        	<iframe src="index/clock.html" height="407" width="296" frameborder="0" scrolling="no"
            		marginheight="0" marginwidth="0" id="clockFrame" name="clockFrame"></iframe>
</div>
        <!-- CLOCK END -->
        
        <!-- MAIN START -->
      	<div id = "main">
        	<div id = "title">≡修改密码≡
            <hr />
            </div>
        	<div id = "modifyPwd">
            	<form method="post" action="" name="modifyPwdForm" onsubmit="return commit();" onreset="reset();">
                	<table>
                    	<tr>
						  <td title="c1"><label>原 &nbsp;密 &nbsp;码 : </label></td>
                            <td><input type="password" name="prePwd" id="prePwd" /></td>
                        </tr>
                        <tr>
                       	  <td title="c1"><label>新 &nbsp;密 &nbsp;码 : </label></td>
                            <td><input type="password" name="pwd" id="pwd" /></td>
                        </tr>
                    	<tr>
                       	  <td title="c1"><label>确认密码 : </label></td>
                            <td><input type="password" name="pwdTwice" id="pwdTwice" /></td>
                        </tr>
                        <tr>
                       	  <td title="c1"><label>验 &nbsp;证 &nbsp;码 :</label></td>
                            <td><input type="text" name="code" id="code" /></td>
                            <td><span id="codePic"><img src="images/code.jsp" /></span></td>
                        </tr>
                   	</table>
                    <table>
                        <tr>
                        	<td><input type="submit" name="modify" value="确认修改"/></td>
                            <td><input type="reset" name="reset" value="重置"/></td>
                            <td><input type="button" name="cancel" value="取消" onclick=			
                            	"window.location.href= 'admi/admi.jsp';"/></td>
                        </tr>
                    </table>
                </form>
        	</div>
        </div>
  <!-- MAIN END -->
        
  <!-- FOOTER START -->
  <div id = "footer">
  </div>
  <!-- FOOTER END -->
        
  </div>
    <!-- CONTAINER END -->
    
</body>
</html>
